package com.stx.xhb.demo;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.provider.Settings;
import android.util.Log;

import com.stx.xhb.demo.GuideActivity;

import java.lang.reflect.Method;

public class MyReceiver extends BroadcastReceiver {


    public static void setSystemProperty(String key, String value) {
        try {
            Class clz = Class.forName("android.os.SystemProperties");
            Method set = clz.getDeclaredMethod("set", String.class, String.class);
            set.invoke(clz, key, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static String getSystemProperty(String key, String defValue) {
        try {
            Class clz = Class.forName("android.os.SystemProperties");
            Method get = clz.getDeclaredMethod("get", String.class, String.class);
            return String.valueOf(get.invoke(clz, key, defValue));
        } catch (Exception e) {
            e.printStackTrace();
            return defValue;
        }
    }


    @Override
    public void onReceive(Context context, Intent intent) {

        Log.d("MyReceiver", "MyReceiver get boot event");

        if (GuideActivity.isShow != true) {
            Intent i = new Intent(context, MainActivity.class);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(i);
        }
    }
}
